package cyan.gf.util;

import java.io.IOException;
import java.util.Properties;

/**
 * Created by cyan on 2017/2/15.
 * Email:qsyan@vip.qq.com
 */
public class PropReader {

  static Properties properties;

  static String currentPath;

  public static void load(String path) {
    try {
      if (properties == null) {
        properties = new Properties();
      }
      if (currentPath == null || !path.equals(currentPath)) {
        properties.load(PropReader.class.getResourceAsStream(path));
        currentPath = path;
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }

  public static String getString(String key) {
    return properties.getProperty(key);
  }

  public static int getInt(String key) {
    return Integer.valueOf(getString(key));
  }

}
